package com.siblings.loan.ui.loan.fm

import android.view.LayoutInflater
import android.view.View
import com.lib.base.utils.TitleBarUtil
import com.siblings.loan.databinding.FmLoanUncreditedBinding
import com.siblings.loan.http.HttpHelper
import com.siblings.loan.ui.loan.impl.SibLoanLimitPresenterImpl
import com.siblings.loan.ui.loan.view.ISibLoanLimitView
import com.siblings.loan.ui.steps.act.SibStepsAct
import com.siblings.loan.ui.tab.act.SibMainAct
import com.siblings.loan.ui.user.act.SibMessageAct
import com.siblings.loan.utils.event.SibEventType
import com.siblings.loan.utils.helper.TestDataLibInvoke
import com.siblings.mvp.MvpFm
import org.json.JSONObject

/**
 * SiblingsLoan
 * @Author wwdeng
 * @CreateTime: 2024/7/8 18:12
 * @Annotation：贷款 - 未授信
 */
class SibLoanUncreditedFm: MvpFm<ISibLoanLimitView,SibLoanLimitPresenterImpl>(),ISibLoanLimitView {
    lateinit var binding: FmLoanUncreditedBinding
    override fun getSibRootView(inflater: LayoutInflater): View {
        binding = FmLoanUncreditedBinding.inflate(inflater)
        return binding.root
    }

    override fun createMvpPresenter(): SibLoanLimitPresenterImpl {
        return SibLoanLimitPresenterImpl(context)
    }

    override fun initSibView() {
        binding.behindLayout.setPadding(0,TitleBarUtil.getStatusBarHeight(),0,0)
    }

    override fun initSibListener() {
        binding.imgMenu.setOnClickListener {
            val tabAct = context as SibMainAct
            tabAct.showSibMenuFragment("Loan Uncredited Page")
        }
        binding.imgMessage.setOnClickListener {
            onIntent(SibMessageAct::class.java)
        }
        //完善流程
        binding.btnApply.setOnClickListener {
            //上报
            TestDataLibInvoke.sycData()
            mvpPresenter.checkSibAllPermissionsAgree()
        }
    }

    override fun initSibData() {
        mvpPresenter.loadSibAllPermissionsAction()
    }

    /**
     * 设置贷款额度信息
     */
    override fun showSibLoanLimitInfo(data: JSONObject) {
    }

    /**
     * 展示完善流程页面
     */
    override fun showSibCheckPermissionSuccess() {
        onIntent(SibStepsAct::class.java)
    }

    override fun onStart() {
        super.onStart()
        HttpHelper.addSibEventAction(SibEventType.PAGE.SIB_PAGE_LOAN_UNCREDITED_START,"")
    }

    override fun onDestroy() {
        super.onDestroy()
        HttpHelper.addSibEventAction(SibEventType.PAGE.SIB_PAGE_LOAN_UNCREDITED_END,"")
    }

}